package pers.wensheng.patterns.behavioral_pattern.observer_pattern.my_impl;

import pers.wensheng.patterns.behavioral_pattern.observer_pattern.my_impl.entity.SubscriptionSubject;
import pers.wensheng.patterns.behavioral_pattern.observer_pattern.my_impl.entity.WeiXinUser;

/**
 * 观察者模式
 * 又被称为  发布-订阅模式（Publish/Subscribe）
 */
public class Client {
    public static void main(String[] args) {
        //创建公众号对象
        SubscriptionSubject subject = new SubscriptionSubject();
        //订阅公众号
        subject.attach(new WeiXinUser("sun"));
        subject.attach(new WeiXinUser("wen"));
        subject.attach(new WeiXinUser("sheng"));
        //公众号更新
        subject.notify("公众号更新了");
    }
}
